package com.example.tellwin.mine.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.tellwin.R;
import com.example.tellwin.mine.bean.ShareRecordBean;
import com.example.tellwin.view.ContentTextView;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : LinZePeng
 * @date : 2020/11/18
 * @Describe ：
 **/
public class ShareRecordAdapter extends RecyclerView.Adapter<ShareRecordAdapter.ShareRecordViewHolder> {

    List<ShareRecordBean> shareRecordBeans = new ArrayList<>();
    Context context;

    public void setShareRecordBeans(List<ShareRecordBean> shareRecordBeans) {
        this.shareRecordBeans = shareRecordBeans;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ShareRecordViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        context = parent.getContext();
        return new ShareRecordViewHolder(LayoutInflater.from(context).inflate(R.layout.item_share_record, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull ShareRecordViewHolder holder, int position) {
        ShareRecordBean shareRecordBean = shareRecordBeans.get(position);
        holder.titleTv.setText(shareRecordBean.getTitle());
       // holder.sharePeopleTv.setTvStr(shareRecordBean.getSharePeople());
        holder.getScoreTv.setTvStr(shareRecordBean.getIntegral());
        holder.timeTv.setTvStr(shareRecordBean.getCreateTime());
    }

    @Override
    public int getItemCount() {
        return shareRecordBeans.size();
    }

    class ShareRecordViewHolder extends RecyclerView.ViewHolder {

        TextView titleTv;
        ContentTextView sharePeopleTv;
        ContentTextView getScoreTv;
        ContentTextView timeTv;

        public ShareRecordViewHolder(@NonNull View itemView) {
            super(itemView);
            titleTv = (TextView) itemView.findViewById(R.id.title_tv);
            sharePeopleTv = (ContentTextView) itemView.findViewById(R.id.share_people_tv);
            getScoreTv = (ContentTextView) itemView.findViewById(R.id.get_score_tv);
            timeTv = (ContentTextView) itemView.findViewById(R.id.time_tv);
        }
    }
}
